import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    // 路径前加一个 @ 意思便是 /src 下的路径
    path: '/login',
    name: 'login',
    component: () => import('../../src/views/login/')
  },
  {
    path: '/',
    component: () => import('../../src/views/layout/'),
    children: [
      {
        path: '',
        name: 'home',
        component: () => import('../../src/views/home/')
      }, {
        path: '/video',
        name: 'video',
        component: () => import('../../src/views/video/')
      }, {
        path: '/my',
        name: 'my',
        component: () => import('../../src/views/my/')
      }, {
        path: '/qa',
        name: 'qa',
        component: () => import('../../src/views/qa/')
      }
    ]
  },
  {
    path: '/search',
    name: 'searcharticle',
    component: () => import('../../src/views/artSearch/SearchArticle')
  },
  {
    path: '/article/:articleId',
    name: 'article',
    component: () => import('../../src/views/article/Article'),
    // 开启props传参，动态路由参数映射到props，否则需要通过 this.$route.params.xxx 获取
    props: true
  },
  {
    path: '/user/profile',
    name: 'userprofile',
    component: () => import('../../src/views/user-profile')
  }
]

const router = new VueRouter({
  routes
})

export default router
